var express = require('express');
var URL = require('url');//请求引入url
//var User = require('./user');//引入user
var router = express.Router();

/* GET users listing. */
router.get('/', function(req, res, next) {
  res.send('respond with a resource');
});


//获取用户信息接口（写死！）
router.get('/getUserInfo', function(req, res, next) {

    var user = new User();
    var params = URL.parse(req.url, true).query;

 if(params.id == '1') {

    user.name = "ligh";
    user.age = "1";
    user.city = "北京市";

}else{    
    user.name = "SPTING";
    user.age = "1";
    user.city = "杭州市";
}

  var response = {status:1,data:user};
  res.send(JSON.stringify(response));

});

//调用方式
//http://localhost:3000/users/getUserInfo?id=1
//或者
//http://localhost:3000/users/getUserInfo?id=2


module.exports = router;
